package com.neuedu.web;

import com.neuedu.pojo.CadreTable;
import com.neuedu.pojo.Result;
import com.neuedu.service.CadreTableService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/adminToCadre")
@Tag(name="管理员管理干部")
public class AdminToCadreController {
    @Resource
    private CadreTableService cadreTableService;

    @PostMapping("/addCadreTable")
    public Result<Void> addCadreTable(@RequestBody CadreTable cadreTable) {
        return this.cadreTableService.addCadreTable(cadreTable);
    }

    @GetMapping("/getCadreTables")
    public Result<List<CadreTable>> getCadreTables(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name = "name",defaultValue = "")String name,
            @RequestParam(name = "role",defaultValue = "")String role) {
        return this.cadreTableService.getCadreTables(currentPage,pageSize,name,role);
    }

    @PutMapping("/updateCadreTable")
    public Result<Void> updateCadreTable(@RequestBody CadreTable cadreTable) {
        return this.cadreTableService.updateCadreTable(cadreTable);
    }

    @DeleteMapping("/deleteCadreTable/{id}")
    public Result<Void> deleteCadreTable(@PathVariable("id") Integer id) {
        return this.cadreTableService.deleteCadreTable(id);
    }
}
